home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / router.lwm < prev    next >
Text File  |  1993-12-13  |  3KB  |  129 lines

  1. /* CMD: Router
  2.  * Bevel Polygons with multi=level bevels
  3.  * By Arnie Cachelin © 1992, 1993 NewTek Inc. */
  4.  
  5. styles = 'Round Hollow StairStep'
  6. typ=1
  7. steps=5
  8. deep = 0.1
  9. wide = 0.02
  10. call addlib "rexxsupport.library", 0, -30, 0
  11. libadd = addlib("LWModelerARexx.port",0)
  12. signal on error
  13. signal on syntax
  14. MATHLIB="rexxmathlib.library"
  15. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  16.   IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  17.     call notify(1,"!Can't find "MATHLIB)
  18.     exit
  19.     END
  20. call req_begin 'Router'
  21. id_typ = req_addcontrol("Type", "CH",Styles)
  22. id_deep = req_addcontrol("Depth", 'n', 1)
  23. id_wide = req_addcontrol("Edge Width", 'n', 1)
  24. id_steps = req_addcontrol("Steps", 'n')
  25. id_corn = req_addcontrol("Bevel on Corner",'B')
  26. call req_setval id_typ, typ,1
  27. call req_setval id_deep, deep,0.1
  28. call req_setval id_wide, wide,0.02
  29. call req_setval id_steps, steps,5
  30.  
  31. if (~req_post()) then do
  32.     call req_end
  33.     exit
  34. end
  35. typ = req_getval(id_typ)
  36. wide = req_getval(id_wide)
  37. deep = req_getval(id_deep)
  38. steps = req_getval(id_steps)
  39. corn =  req_getval(id_corn)
  40. /* axis = translate(req_getval(axId),'XYZ','123') */
  41. call req_end
  42. sc45=sin(3.14159/4)
  43. call sel_mode(USER)
  44. select
  45.   when typ = 1 then
  46.     if ~corn then call Bevel_Round
  47.     else call Bevel_CornRound
  48.   when typ = 2 then
  49.     if ~corn then call Bevel_Hollow
  50.     else call Bevel_CornHollow
  51.   when typ = 3 then call Bevel_StairStep
  52.   otherwise nop
  53.   end
  54. if (libadd) then call remlib("LWModelerARexx.port")
  55. exit
  56.  
  57. syntax:
  58. error:
  59.   call end_all
  60.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  61.   if (libadd) then call remlib("LWModelerARexx.port")
  62.     exit
  63.  
  64. Bevel_Chisel:
  65.     call shapebevel(-wide wide (-wide) deep/2)
  66.     return
  67.  
  68. Bevel_Round:
  69.     n = steps
  70.     pat = ''
  71.     do i=1 to n
  72.         a = 3.14159/2 * i / n
  73.         pat = pat (1-cos(a))*wide (sin(a)*deep)
  74.       end i
  75.     call shapebevel(pat)
  76.     say pat
  77.     return
  78.  
  79. Bevel_CornRound:
  80.     n = steps
  81.     pat = ''
  82.     do i=1 to n
  83.         a = 3.14159/4 * i / n
  84.       a = a + 3.14159/4
  85.         pat = pat 2*(sc45-cos(a))*wide/sc45 2*(sin(a)-sc45)*deep/(sc45)
  86.       end i
  87.     call shapebevel(pat)
  88.     say pat
  89.     return
  90.  
  91. Bevel_Hollow:
  92.     n = steps
  93.     pat = ''
  94.     do i=1 to n
  95.         a = 3.14159/2 * i / n
  96.         pat = pat (sin(a)*wide) (1-cos(a))*wide
  97.       end i
  98.     call shapebevel(pat )
  99.     return
  100.  
  101. Bevel_CornHollow:
  102.     n = steps
  103.     pat = ''
  104.     do i=1 to n
  105.         a = 3.14159/4 * i / n
  106.         pat = pat ( (sin(a)-sc45 )*wide) (sc45-cos(a))*wide
  107.       end i
  108.     call shapebevel(pat)
  109.     return
  110.  
  111. Bevel_StairStep:
  112.     n = steps
  113.     pat = ''
  114.     w=wide/n
  115.     d=deep/n
  116.     do=0
  117.     wo=0
  118.     do i=1 to n
  119.         pat = pat w do w d
  120.       do=d
  121.       wo=w
  122.       w=w+wide/n
  123.       d=d+deep/n
  124.       end i
  125.     call shapebevel(pat)
  126.     return
  127.  
  128.  
  129.